package com.art.coconut.compare;

import java.util.Date;
import java.util.Objects;

public class BaseComparator<T>  implements Comparator<T>{
    @Override
    public int compare(T o1, T o2) {
        if((!Objects.isNull(o1) && Objects.isNull(o2)) || (Objects.isNull(o1) && !Objects.isNull(o2))){
            return -1;
        }
        if(o1 instanceof Date){
            return ((Date) o1).compareTo((Date) o2);
        }else {
            if(o1==o2 || o1.equals(o2)){
                return 0;
            }
        }
        return -1;
    }
}

